#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <list>
using namespace std;

class Solution {
public:
    bool lemonadeChange(vector<int>& bills) {

        int five_num = 0;
        int ten_num = 0;
        for (auto e : bills)
        {
            if (e == 20)
            {
                if (ten_num >= 1 && five_num >= 1)
                {
                    five_num--;
                    ten_num--;
                }
                else if (five_num >= 3)
                {
                    five_num -= 3;
                }

                else {
                    return false;
                }
            }

            else if (e == 10)
            {
                if (five_num < 1)
                {
                    return false;
                }
                five_num--;
                ten_num++;
            }

            else
            {
                five_num++;
            }
        }

        return true;
    }



};